package com.shanwen.shopping.activity;

import android.content.Intent;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.shanwen.shopping.R;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 充值页面
 */
public class ChargingActivity extends AppBaseActivity {


    @BindView(R.id.tvTimer)
    TextView tvTimer;

    private CountDownTimer timer;

    @Override
    public int getLayoutResId() {
        return R.layout.activity_charging;
    }

    @Override
    public void initView() {
        super.initView();
        setTitle("充值进行中");
        setBackEnabled(true);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // TODO: add setContentView(...) invocation
        ButterKnife.bind(this);
        timer = new CountDownTimer(2 * 60 * 1000, 1000) {

            @Override
            public void onTick(long millisUntilFinished) {
                tvTimer.setText((millisUntilFinished / 1000) + "s");
            }

            @Override
            public void onFinish() {
                Intent intent = new Intent(ChargingActivity.this,NewMainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                startActivity(intent);
            }
        }.start();
    }

    @Override
    protected void onPause() {
        super.onPause();
        timer.cancel();
    }
}
